package com.songshuai.customer.client.service.impl;

import com.songshuai.customer.client.feign.PanguApiClient;
import com.songshuai.customer.client.service.MyService;
import com.songshuai.webapi.baseapi.enumerations.ResultStatus;
import com.songshuai.webapi.baseapi.exception.BusinessException;
import com.songshuai.webapi.baseapi.pojo.QueryResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 客户助手-我
 * @Author: hst
 * @Date: 2019/3/25 11:19
 */
@Slf4j
@Service
public class MyServiceImpl implements MyService {

    @Autowired
    private PanguApiClient custMeetingClient;

    /**
     * 我的咨询顾问
     *
     * @return
     */
    @Override
    public QueryResponse mySale(String currentUserId) {

        try{
            return custMeetingClient.getSale(currentUserId);
        }catch (Exception e) {
            log.error("api/cust/my/mySale", e);
            throw new BusinessException(ResultStatus.ERROR_SEARCH_FAILED.getErrorMsg(), ResultStatus.FAILOfficial);
        }
    }

    /**
     * 我参与过的活动
     * @param currentUserId
     * @return
     */
    public QueryResponse queryActivityList(String currentUserId) {
        QueryResponse listQueryResponse = custMeetingClient.queryActivityList(currentUserId);
        if (ResultStatus.SUCCESS.getErrorCode() == listQueryResponse.getCode()) {
            return listQueryResponse;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }

    @Override
    public QueryResponse queryActivityCount(String currentUserId) {
        QueryResponse queryResponse = custMeetingClient.queryActivityCount(currentUserId);
        if(ResultStatus.SUCCESS.getErrorCode() == queryResponse.getCode()){
            return queryResponse;
        }
        return new QueryResponse<>(ResultStatus.ERROR_SEARCH_FAILED);
    }
}
